<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <title><!--{$lang.page.index.title}--></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/lay/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/lay/layui/index.css" media="all">
</head>
<body>

<div class="layui-fluid">
     <div class="layui-card">

      <div class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label"><!--{$lang.page.table.account}--></label>
            <div class="layui-input-inline">
              <input type="text" name="username" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label"><!--{$lang.page.table.phone}--></label>
            <div class="layui-input-inline">
              <input type="text" name="mobile" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label"><!--{$lang.page.table.realname}--></label>
            <div class="layui-input-inline">
              <input type="text" name="realname" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
            </div>
          </div>

            <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.type}--></label>
              <div class="layui-input-inline" >
                 <select name="roletype">
                     <option value=""><!--{$lang.page.public.select}--></option>
                   <!--{foreach item=item from=$rolelist}-->
                     <option  value="<!--{$item.id}-->" ><!--{$item.title}--></option>
                   <!--{/foreach}-->
              </select>
              </div>
              </div>

          <div class="layui-inline">
            <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="search">
              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
          </div>
        </div>
      </div>
      </div>
      
      <div class="layui-card-body">
            <table id="datalist" lay-filter="datalist"></table>
            <script type="text/html" id="toolbartop">
                <button class="layui-btn layui-btn-sm" lay-event="redatalist"><!--{$lang.page.public.refresh}--></button>
                <button class="layui-btn layui-btn-sm add muetool"><!--{$lang.page.public.add}--></button>
                <button class="layui-btn layui-btn-sm batch"><!--{$lang.page.table.batchadd}--></button>
            </script>
            <script type="text/html" id="zizeng">{{d.LAY_TABLE_INDEX+1}}</script>
            <script type="text/html" id="bartool">
                <a class="layui-btn layui-btn-xs edit" data-set="{{d.aid}}"><!--{$lang.page.public.edit}--></a>
                <a class="layui-btn layui-btn-danger layui-btn-xs del" data-set="{{d.aid}}"><!--{$lang.page.public.del}--></a>
            </script>
        </div>

    </div>
<script src="/static/lay/layui/layui.js"></script>
<script type="text/javascript">
    layui.config({
       base: '/static/lay/' //静态资源所在路径
    }).extend({
        roleper:'lib/roleper'
        , xadmin:'lib/xadmin'
        , lang:'lib/lang'
    }).use(['roleper', 'xadmin', 'table', 'lang'], function () {

            var $ = layui.$
            , form = layui.form
            , table = layui.table
            , roleper = layui.roleper
            , toolbar = roleper.showtool({mid:62,per:[{sys:'add'},{sys:'edit'},{sys:'batch'},{sys:'del'}]}) ? false : true; //根据权限是否显示操作列
            var lang=layui.lang.init();
            table.render({
            elem: '#datalist'
            , height: 'auto'
            , url: 'list' //数据接口
            , method: 'post'
            , where: {"type":"<!--{$type}-->"}
            , page: true //开启分页
            , limit: 10
            , toolbar: '#toolbartop'
            , defaultToolbar: ['filter', 'exports', 'print']
            , cols: [[ //表头
                {field: 'zizeng', title: function(){ return lang.serial }, align: "center", fixwidth: true, width: 80, templet:'#zizeng'},
                {field: 'username', title: function(){ return lang.account }},
                {field: 'un_id', title: function(){ return lang.only+' ID' },width: 260, hide:true},
                {field: 'usercode', title: function(){ return lang.promotion }, hide:true},
                {field: 'uid', title:'UID', width: 80, hide:true, align:'center'},
                {field: 'realname', title: function(){ return lang.realname }},
                {field: 'mobile', title: function(){ return lang.phone }},
                {field: 'subrealname', title: function(){ return lang.beto+lang.agent },hide:true},
                {field: 'subusername', title: function(){ return lang.beto+lang.agent+lang.account },hide:true},
                {field: 'header_url', title: function(){ return lang.header}, hide:true,
                   templet: function(d) {
                       if (d.header_url) {
                            return '<img src="'+d.header_url+'" style="cursor:pointer;width:30px; height:30px;" onclick="xadmin.imgOpen({url:\''+d.header_url+'\',title:\''+lang.header+'\'})">';
                        } else {
                            return '';
                        }
                      }

                },
                {field: 'type', title: function(){ return lang.type }},
                {field: 'status', title: function(){ return lang.status },
                 templet: function(d) {
                       if (d.status == 1) {
                            return '<button class="layui-btn layui-btn-xs">'+lang.normal+'</button>';
                        } else {
                            return '<button class="layui-btn layui-btn-primary layui-btn-xs">'+lang.close+'</button>';
                        }
                      }
                  },
                {field: 'ranges', title: function(){ return lang.scope },
                 templet: function(d) {
                       if (d.ranges == 1) {
                            return '<button class="layui-btn layui-btn-danger layui-btn-xs">'+lang.allrole+'</button>';
                        } else {
                            return '<button class="layui-btn layui-btn-xs">'+lang.oneself+'</button>';
                        }
                      }
                },
                {fixed: '', title: function(){ return lang.operation }, width: 260, align: 'center', toolbar: '#bartool', hide:toolbar}
            ]],
             done: function() {
                    layer.closeAll('loading');
                    roleper.render({mid:62,per:[{sys:'add',method:'open'},{sys:'edit',method:'open'},{sys:'batch',method:'open'},{sys:'del',method:'del'}],full:true});//law 设置长宽，full是否全屏，par父窗口打开
                }
            });

        //监听搜索
        form.on('submit(search)', function(data){
          var field = data.field;
          //执行重载
           table.reload('datalist', {
            where: field
            ,page: {
              curr: 1 // 设定当前页为1
            }
          });
        });

        table.on('toolbar(datalist)', function(obj){
            switch(obj.event){
                case 'redatalist':
                    //执行重载
                    table.reload('datalist');
                break;
                case 'alllist':
                    //重新载入页面
                    window.location.href="list";
                break;
            };
        }); 
    });
</script>
</body>
</html>